function CustomerNear_Code() {

	var buffer = new StringBuffer();
	buffer.append('<div id="mapnear" class="mapnear"></div>');
	return buffer.toString();
};
function Init_CustomerNear(){
	mapnear=new plus.maps.Map("mapnear");
	mapnear.hide();
	setTimeout(function(){
		mapnear.getUserLocation(function(state,pos){
							if(0==state){
								
								mapnear.centerAndZoom(pos,15);
								var marker=new plus.maps.Marker(pos);
								mapnear.addOverlay(marker);
								mapnear.show(); 
								 
							}
		});
	},10);
};

function CustomerNear_Data(data) {
	var buffer = new StringBuffer();
	$(data).each(function(i,info){
		buffer.append('<div class="customerlist border-bottom" id="'+info.ID+'"><div class="customername">'+info.Name+'</div><div class="customerinfo"><div class="state">'+info.State+'</div><div class="lastconntime">距离：'+info.Distance+' 米</div></div></div>');
	});
	return buffer.toString();
};

function Receive_CustomerNear(pageindex)
{
	$(".customerlist").remove();
	mapnear.getUserLocation(function(state,point){
		if(0==state){
			var data = {};
			data.act = "Find_CustomerNear";
			data.userid=userid;
			data.comid=comid;
			data.pageindex=pageindex;
			data.source=source;
			data.pagesize=1000;
			data.lat=point.latitude;
			data.lng=point.longitude;
			data.sign=GetSign(data.act);
			mui.getJSON(crm_domain, data, function(json) {
				
				if(json.data.list.length>0)
				{
					if(pageindex==1)
					{
						$("#contentlist201").html(CustomerNear_Data(json.data.list));
					}else{
						$("#contentlist201").append(CustomerNear_Data(json.data.list));
					}
					
					if(json.data.list.length!=data.pagesize)
					{
						$("#loading201").html("");
					}else{
						$("#loading201").html('<img src="img/loading.gif"/>');
					}
				}else
				{
					
					if(pageindex==1)
					{
						$("#loading201").html("主人，没有找到附近的客户"); 
					}
					else
					{
						$("#loading201").html("没有更多了");
					}
				}
				
			});
		}
	});
};


